package com.yunfeisoft.business.model;

import com.applet.base.ServiceModel;
import com.applet.sql.record.TransientField;
import com.applet.utils.DateUtils;
import com.yunfeisoft.model.Attachment;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * ClassName: PmsProduct
 * Description: 商品表
 *
 * @Author: Jackie liu
 * Date: 2020-06-02
 */
@Entity
@Table(name = "PMS_PRODUCT")
public class PmsProduct extends ServiceModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @Column
    private String brandId;

    /**
     * 品牌分类id
     */
    @Column
    private String productCategoryId;

    /**
     * 运费模版id
     */
    @Column
    private String feightTemplateId;

    /**
     * 品牌属性分类id
     */
    @Column
    private String productAttributeCategoryId;

    /**
     * 名称
     */
    @Column
    private String name;

    /**
     * 图片
     */
//    @Column
//    private String pic;

    /**
     * 货号
     */
    @Column
    private String productSn;

    /**
     * 上架状态：0->下架；1->上架
     */
    @Column
    private Integer publishStatus;

    /**
     * 新品状态:0->不是新品；1->新品
     */
    @Column
    private Integer newStatus;

    /**
     * 推荐状态；0->不推荐；1->推荐
     */
    @Column
    private Integer recommandStatus;

    /**
     * 审核状态：0->未审核；1->审核通过
     */
    @Column
    private Integer verifyStatus;

    /**
     * 排序
     */
    @Column
    private Integer sort;

    /**
     * 销量
     */
    @Column
    private Integer sale;

    /**
     * 价格
     */
    @Column
    private BigDecimal price;

    /**
     * 促销价格
     */
    @Column
    private BigDecimal promotionPrice;

    /**
     * 市场价
     */
    @Column
    private BigDecimal originalPrice;

    /**
     * 赠送的成长值
     */
    @Column
    private Integer giftGrowth;

    /**
     * 赠送的积分
     */
    @Column
    private Integer giftPoint;

    /**
     * 限制使用的积分数
     */
//    @Column
//    private Integer usePointLimit;

    /**
     * 副标题
     */
    @Column
    private String subTitle;

    /**
     * 库存
     */
//    @Column
//    private Integer stock;

    /**
     * 库存预警值
     */
//    @Column
//    private Integer lowStock;

    /**
     * 单位
     */
    @Column
    private String unit;

    /**
     * 是否为预告商品：0->不是；1->是
     */
    @Column
    private Integer previewStatus;

    /**
     * 商品重量，默认为克
     */
    @Column
    private BigDecimal weight;

    /**
     * 以逗号分割的产品服务：1->无忧退货；2->快速退款；3->免费包邮
     */
    @Column
    private String serviceIds;

    /**
     * 关键字
     */
    @Column
    private String keywords;

    /**
     * 备注
     */
    @Column
    private String note;

    /**
     * 图片
     */
    @Column
    private String albumPics;

    /**
     * 详情标题
     */
    @Column
    private String detailTitle;

    /**
     * 促销开始时间
     */
    @Column
    private Date promotionStartTime;

    /**
     * 促销结束时间
     */
    @Column
    private Date promotionEndTime;

    /**
     * 活动限购数量
     */
//    @Column
//    private Integer promotionPerLimit;

    /**
     * 促销类型：0->没有促销使用原价;1->使用促销价；2->使用会员价；3->使用阶梯价格；4->使用满减价格；5->限时购
     */
    @Column
    private Integer promotionType;

    @TransientField
    private String brandName;
    @TransientField
    private String productCategoryName;

    private String content;
    private String[] imageIds;
    private List<PmsProductLadder> ladderList;
    private List<PmsProductFullReduction> fullReductionList;
    private List<PmsSkuStock> skuStockList;
    private List<PmsProductAttributeValue> productAttributeValueList;
    private List<Attachment> attachmentList;

    public String getPromotionStartTimeStr() {
        if (promotionStartTime != null) {
            return DateUtils.dateTimeToString(promotionStartTime);
        }
        return null;
    }

    public String getPromotionEndTimeStr() {
        if (promotionEndTime != null) {
            return DateUtils.dateTimeToString(promotionEndTime);
        }
        return null;
    }

    public String getVerifyStatusStr() {
        return ProductVerifyStatusEnum.valueOf(verifyStatus);
    }

    public String getBrandId() {
        return brandId;
    }

    public void setBrandId(String brandId) {
        this.brandId = brandId;
    }

    public String getProductCategoryId() {
        return productCategoryId;
    }

    public void setProductCategoryId(String productCategoryId) {
        this.productCategoryId = productCategoryId;
    }

    public String getFeightTemplateId() {
        return feightTemplateId;
    }

    public void setFeightTemplateId(String feightTemplateId) {
        this.feightTemplateId = feightTemplateId;
    }

    public String getProductAttributeCategoryId() {
        return productAttributeCategoryId;
    }

    public void setProductAttributeCategoryId(String productAttributeCategoryId) {
        this.productAttributeCategoryId = productAttributeCategoryId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProductSn() {
        return productSn;
    }

    public void setProductSn(String productSn) {
        this.productSn = productSn;
    }

    public Integer getPublishStatus() {
        return publishStatus;
    }

    public void setPublishStatus(Integer publishStatus) {
        this.publishStatus = publishStatus;
    }

    public Integer getNewStatus() {
        return newStatus;
    }

    public void setNewStatus(Integer newStatus) {
        this.newStatus = newStatus;
    }

    public Integer getRecommandStatus() {
        return recommandStatus;
    }

    public void setRecommandStatus(Integer recommandStatus) {
        this.recommandStatus = recommandStatus;
    }

    public Integer getVerifyStatus() {
        return verifyStatus;
    }

    public void setVerifyStatus(Integer verifyStatus) {
        this.verifyStatus = verifyStatus;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Integer getSale() {
        return sale;
    }

    public void setSale(Integer sale) {
        this.sale = sale;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getPromotionPrice() {
        return promotionPrice;
    }

    public void setPromotionPrice(BigDecimal promotionPrice) {
        this.promotionPrice = promotionPrice;
    }

    public BigDecimal getOriginalPrice() {
        return originalPrice;
    }

    public void setOriginalPrice(BigDecimal originalPrice) {
        this.originalPrice = originalPrice;
    }

    public Integer getGiftGrowth() {
        return giftGrowth;
    }

    public void setGiftGrowth(Integer giftGrowth) {
        this.giftGrowth = giftGrowth;
    }

    public Integer getGiftPoint() {
        return giftPoint;
    }

    public void setGiftPoint(Integer giftPoint) {
        this.giftPoint = giftPoint;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Integer getPreviewStatus() {
        return previewStatus;
    }

    public void setPreviewStatus(Integer previewStatus) {
        this.previewStatus = previewStatus;
    }

    public BigDecimal getWeight() {
        return weight;
    }

    public void setWeight(BigDecimal weight) {
        this.weight = weight;
    }

    public String getServiceIds() {
        return serviceIds;
    }

    public void setServiceIds(String serviceIds) {
        this.serviceIds = serviceIds;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getAlbumPics() {
        return albumPics;
    }

    public void setAlbumPics(String albumPics) {
        this.albumPics = albumPics;
    }

    public String getDetailTitle() {
        return detailTitle;
    }

    public void setDetailTitle(String detailTitle) {
        this.detailTitle = detailTitle;
    }

    public Date getPromotionStartTime() {
        return promotionStartTime;
    }

    public void setPromotionStartTime(Date promotionStartTime) {
        this.promotionStartTime = promotionStartTime;
    }

    public Date getPromotionEndTime() {
        return promotionEndTime;
    }

    public void setPromotionEndTime(Date promotionEndTime) {
        this.promotionEndTime = promotionEndTime;
    }

    public Integer getPromotionType() {
        return promotionType;
    }

    public void setPromotionType(Integer promotionType) {
        this.promotionType = promotionType;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String[] getImageIds() {
        return imageIds;
    }

    public void setImageIds(String[] imageIds) {
        this.imageIds = imageIds;
    }

    public List<PmsProductLadder> getLadderList() {
        return ladderList;
    }

    public void setLadderList(List<PmsProductLadder> ladderList) {
        this.ladderList = ladderList;
    }

    public List<PmsProductFullReduction> getFullReductionList() {
        return fullReductionList;
    }

    public void setFullReductionList(List<PmsProductFullReduction> fullReductionList) {
        this.fullReductionList = fullReductionList;
    }

    public List<PmsSkuStock> getSkuStockList() {
        return skuStockList;
    }

    public void setSkuStockList(List<PmsSkuStock> skuStockList) {
        this.skuStockList = skuStockList;
    }

    public List<PmsProductAttributeValue> getProductAttributeValueList() {
        return productAttributeValueList;
    }

    public void setProductAttributeValueList(List<PmsProductAttributeValue> productAttributeValueList) {
        this.productAttributeValueList = productAttributeValueList;
    }

    public List<Attachment> getAttachmentList() {
        return attachmentList;
    }

    public void setAttachmentList(List<Attachment> attachmentList) {
        this.attachmentList = attachmentList;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getProductCategoryName() {
        return productCategoryName;
    }

    public void setProductCategoryName(String productCategoryName) {
        this.productCategoryName = productCategoryName;
    }

    /**
     * 审核状态
     */
    public enum ProductVerifyStatusEnum {

        NEW(1, "待审核"),
        ACCEPT(2, "审核通过"),
        REJECT(3, "审核驳回");

        private int value;
        private String label;

        private ProductVerifyStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (ProductVerifyStatusEnum loop : ProductVerifyStatusEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }

    /**
     * 促销类型：0->没有促销使用原价;1->使用促销价；2->使用会员价；3->使用阶梯价格；4->使用满减价格；5->限时购
     */
    public enum ProductPromotionTypeEnum {

        NOTHING(0, "无优惠"),
        TEHUI(1, "特惠促销"),
        HUIYUAN(2, "会员价"),
        JIETI(3, "阶梯价格"),
        MANJIAN(4, "满减价格"),
        XIANSHI(5, "限时购");

        private int value;
        private String label;

        private ProductPromotionTypeEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (ProductPromotionTypeEnum loop : ProductPromotionTypeEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }
}